<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean"%>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="/WebFinalProject/css/FinalProjectCSS.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Forum Discussion</title>

<script type="text/javascript" src="table.js"></script>
<script type="text/javascript" src="js/MasterJS.js"></script>
<script type="text/javascript">
	function goToEditPost(task,id, id2) {
			document.forms[0].task.value = task;
			document.forms[0].idThread.value = id;
			document.forms[0].idEdit.value = id2;
			//alert(task + ', '+ id + ', ' + id2);
			document.forms[0].submit();
	}
	
	function goToComment(task,id) {
		document.forms[0].task.value = task;
		document.forms[0].idThread.value = id;
		//alert(task);
		document.forms[0].submit();
	}
</script>

<%
	if(session.getAttribute("result") != null)
	{
		String message = session.getAttribute("result").toString();
		%>
			<script type="text/javascript">
				window.alert('<%=message%>');
			</script>
		<%
		session.removeAttribute("result");
	}
%> 

</head>
<body>
<center>
		<table width="1000px" class="bodyTable boxShadow">
		
			<!-- Header -->
			<tr>
				<td colspan="2"><%@include file="/include/Header.jsp"%></td>
			</tr>
		
			<!-- Content -->
			<tr>
				<td rowspan="2" width="200px" class="navigationBox"><%@include file="/include/Navigation.jsp"%></td>
				<td align="left" class="headerBox blueBackground">
					<a href="javascript:flyToPage('forumPage');">Forum Discussion</a> > 
					<bean:write name="forumThreadForm" property="judulThread"/>
				</td>
			</tr>
			<tr>
				<td align="center"  class="contentStyle" style="padding: 5px 7px;"><br>
					<html:form action="/Forum" method="post">
					
<!-- -------------------------------------- Koding disini ----------------------------------------------------------------------------- -->
						<html:hidden property="task"/>
						<html:hidden property="idThread"/>
						<html:hidden property="idEdit"/>
						<br/>
						<table border="0" width="95%" align="center" class="boxShadow  example table-autosort  table-autopage:5 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount" id="t1">
							<thead>
							<tr class="headerBox formHeaderBackground">
								<th colspan="3" class="formListStyle">Comments</th>
							</tr>
							</thead>
							<tbody>
							<logic:notEmpty name="forumThreadForm" property="listComments">
							<logic:iterate id="listData2" name="forumThreadForm" property="listComments">
								<tr class="formListBackground">
									<td colspan="3">
										<div class="formListStyle" >
											<table width="100%">
												<tr>
													<td align="center"style="vertical-align: top;" rowspan="2" width="100px">
														<img src="images/default PP.png" width="75px"/>
														<b><bean:write name="listData2" property="userId"></bean:write></b>
													</td>
													<td style="vertical-align: top; padding:2px 10px;" colspan="2">
														<bean:write name="listData2" property="comments" filter="false"></bean:write>
													</td>
												</tr>
												<tr>
												<td align="right" style="vertical-align: bottom;" colspan="2">
														<bean:write name="listData2" property="dtmPost"/>&nbsp;
													<% boolean useridcek = false;%>
														<logic:equal value="<%=user.getUserid().toString()%>" property="userId" name="listData2">
															<% useridcek = true; %>
														</logic:equal>
													<%if(user.getRole().toString().equalsIgnoreCase("admin")){
														 useridcek = true;
													}
													if(useridcek){%>
														<img src="images/editButton.png" title="edit post" style="cursor: pointer;" onclick="javascript:goToEditPost('editPost','<bean:write name="listData2" property="forumThreadCommentid"/>','<bean:write name="listData2" property="forumThreadId"/>')"/>
														&nbsp;
														</td>
													<%}%>
												</tr>
<!-- 												<tr> -->
<!-- 													<td align="right" style="vertical-align: bottom;" colspan="2"> -->
<%-- 														<bean:write name="listData2" property="dtmPost"/>&nbsp; --%>
<%-- 														<img src="images/editButton.png" title="edit post" style="cursor: pointer;" onclick="javascript:goToEditPost('editPost','<bean:write name="listData2" property="forumThreadCommentid"/>','<bean:write name="listData2" property="forumThreadId"/>')"/> --%>
<!-- 														&nbsp;									 -->
<%-- 														<a href="javascript:goToEditPost('editPost','<bean:write name="listData2" property="forumThreadCommentid"/>','<bean:write name="listData2" property="forumThreadId"/>')">Edit Post</a> --%>
<!-- 													</td> -->
<!-- 												</tr> -->
											</table>
										</div>
									</td>									
								</tr>
							</logic:iterate>
						</logic:notEmpty>
						</tbody>
						<tfoot>
							<tr class="headerBox formHeaderBackground">
								<td width="75px" class="table-page:previous formListStyle" style="cursor:pointer;">&lt;&lt; Previous</td>
								<td style="text-align:center; vertical-align: middle;">Page <span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td>
								<td width="55px" align="right" class="table-page:next formListStyle" style="cursor:pointer;">Next &gt;&gt;</td>
							</tr>
							<tr>
								<td colspan="3" id="insertButton" title="reply post" align="center" class="greyBackground">						
									<div class="insertButtonGridStyle" onclick="javascript:goToComment('addComment','<bean:write name="listData2" property="forumThreadId"/>');">
										<table>
											<tr>
												<td class="formListStyle"><img src="images/addButton.png"></td>
												<td class="formListStyle"><b>Reply Post</b></td>
											</tr>
										</table>
									</div>									
								</td>
							</tr>	
<!-- 							<tr> -->
<%-- 								<td colspan="3" align="center" class="formListStyle"><input type="button" class="buttonStyle" value="Reply" onclick="javascript:goToComment('addComment','<bean:write name="listData2" property="forumThreadId"/>')" /> </td> --%>
<!-- 							</tr> -->
<!-- 							<tr> -->
<!-- 								<td class="table-page:previous" style="cursor:pointer; padding:5px 7px; width: 20%;">&lt; &lt; Previous</td> -->
<!-- 								<td style="text-align:center; vertical-align: middle; width: 60%;">Page <span id="t1page"></span>&nbsp;of <span id="t1pages"></span></td> -->
<!-- 								<td align="right" class="table-page:next" style="cursor:pointer; vertical-align: middle; padding:5px 7px; width: 20%;">Next &gt; &gt;</td> -->
<!-- 							</tr> -->
<!-- 							<tr> -->
<!-- 								<td colspan="5" align="center" class="headerBox formHeaderBackground"> -->
<!-- 									<span id="t1filtercount"></span>&nbsp;of <span id="t1allcount"></span>&nbsp;rows match filter(s) -->
<!-- 								</td> -->
<!-- 							</tr> -->
<!-- 							<tr class="formListBackground"> -->
<!-- 								<td colspan="5" align="center"><span id="t1filtercount"></span>&nbsp;of <span id="t1allcount"></span>&nbsp;rows match filter(s)</td> -->
<!-- 							</tr> -->
						</tfoot>
						</table>
<!-- -------------------------------------- Sampe disini ----------------------------------------------------------------------------- -->
					
					</html:form><br><br>
				</td>
			</tr>
			
			<!-- Footer -->
			<tr>
				<td align="center" colspan="2" class="headerBox blueBackground">&copy; OME. 2013. All Rights Reserved.</td>
			</tr>
		</table>
	</center>	
</body>
</html>